Brendan Smithyman | January 2015
In [1]:
import numpy as np
import networkx
from zephyr.Problem import SeisFDFDProblem
In [2]:
import matplotlib.pyplot as plt
import matplotlib.cm as cm
import matplotlib
%matplotlib inline
In [3]:
cellSize = 1 # m
freqs = [2e2] # Hz
density = 2700 # units of density
Q = np.inf # can be inf
nx = 164 # count
nz = 264 # count
freeSurf = [False, False, False, False] # t r b l
dims = (nx,nz) # tuple
nPML = 32
rho = np.fliplr(np.ones(dims) * density)
nfreq = len(freqs) # number of frequencies
nky = 4 # number of y-directional plane-wave components
nsp = nfreq * nky # total number of 2D subproblems
velocity = 2500 # m/s
vanom = 500 # m/s
cPert = np.zeros(dims)
cPert[(nx/2)-20:(nx/2)+20,(nz/2)-20:(nz/2)+20] = vanom
c = np.fliplr(np.ones(dims) * velocity)
cFlat = c
c += np.fliplr(cPert)
cTrue = c
srcs = np.array([np.ones(101)*32, np.zeros(101), np.linspace(32, 232, 101)]).T
recs = np.array([np.ones(101)*132, np.zeros(101), np.linspace(32, 232, 101)]).T
nsrc = len(srcs)
nrec = len(recs)
recmode = 'fixed'
geom = {
'src': srcs,
'rec': recs,
'mode': 'fixed',
}
cache = False
cacheDir = '.'
parFac = 2
chunksPerWorker = 0.5 # NB: parFac * chunksPerWorker = number of source array subsets
ensembleClear = False
profile = 'default'
# Base configuration for all subproblems
systemConfig = {
'dx': cellSize, # m
'dz': cellSize, # m
'c': c.T, # m/s
'rho': rho.T, # density
'Q': Q, # can be inf
'nx': nx, # count
'nz': nz, # count
'freeSurf': freeSurf, # t r b l
'nPML': nPML,
'geom': geom,
'cache': cache,
'cacheDir': cacheDir,
'freqs': freqs,
'nky': nky,
'parFac': parFac,
'chunksPerWorker': chunksPerWorker,
'profile': profile,
'ensembleClear': ensembleClear,
}
In [4]:
sp = SeisFDFDProblem(systemConfig)
In [5]:
G = sp.forwardAccumulate()
In [6]:
G.neighbors('Beginning')
Out[6]:
In [7]:
G.predecessors('End')
Out[7]:
In [8]:
def colourCodeNodes(graph):
colours = []
def mapColours(value):
if value < 0:
return (0, 0, 0)
elif value == 0:
return (0, 0, 1)
elif value == 1:
return (0, 1, 0)
elif value == 2:
return (1, 0, 0)
for node in graph.nodes():
status = -1
nodeprops = G.node[node]
if 'job' in nodeprops:
job = nodeprops['job']
status = 1. * job.ready()
if status > 0:
status += 1. * (not job.successful())
colours.append(mapColours(status))
return colours
In [12]:
im = networkx.draw_graphviz(G, with_labels=True, node_color=colourCodeNodes(G))
In [10]:
j = G.node['Wrap: 0, 3, 0']['job']
In [11]:
j.get()
In [11]: